﻿namespace WebService.EF
{
    public static class DbServiceExt
    {
        private static IApplicationBuilder _app;

        public static DbService GetDb()
        {
            var dbScope = _app.ApplicationServices.CreateScope();

            return dbScope.ServiceProvider.GetService<DbService>();
        }

        public static IApplicationBuilder UseDbExt(this IApplicationBuilder app, ConfigurationManager cfgMgr)
        {
            _app = app;
            
            return app;
        }
    }
}
